<template>
    <!-- 监听属性 -->
    <div>
        <button @click="addNum">addNum</button>
        <hr>
        <button @click="addNum1">addNum1</button>
    </div>
</template>

<script>
export default {
     name:'',
    components: {

    },
    props: {

    },
    data() {
        return {
            num: 10,
            num1: 20
        };
    },
    methods: {
        addNum(){
            this.num++
        },
        addNum1(){
            this.num1 += 10
        }
    },
    watch: {
        // 两种写法
        num(newVal,oldVal){
            console.log(newVal,oldVal)
        },
        num1:{
            handler(newVal,oldVal){
                console.log(newVal,oldVal)
            }
        }
    },
    computed: {

    },
    created() {

    },
    mounted() {

    }
};
</script>

<style scoped lang="less">

</style>
